package com.corpgovernment.travelstandard.controller;

import com.corpgovernment.api.travelstandard.bo.AirportTransferStandardDetailRequestBO;
import com.corpgovernment.api.travelstandard.bo.AirportTransferStandardDetailResponseBO;
import com.corpgovernment.api.travelstandard.bo.AirportTransferStandardRequestBO;
import com.corpgovernment.api.travelstandard.bo.AirportTransferStandardResponseBO;
import com.corpgovernment.common.base.JSONResult;
import com.corpgovernment.travelstandard.impl.AirportTransferStandardService;
import com.corpgovernment.travelstandard.vo.*;
import com.corpgovernment.travelstandard.vo.airport.*;
import com.ctrip.corp.obt.generic.utils.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 接送机控制器
 */
@Slf4j
@RestController
@RequestMapping("airportTransfer")
public class AirportTransferStandardManageController {

	@Autowired
	private AirportTransferStandardService airportTransferStandardService;

	/**
	 * 获取接送机差标详情
	 */
	@PostMapping("/get")
	public JSONResult<GetAirportTransferStandardResponseVO> getTransferStandard(@RequestBody @Valid GetAirportTransferStandardRequestVO request) {
		return JSONResult.success(airportTransferStandardService.getStandard(request));
	}

	/**
	 * 新增差标获取模版数据
	 */
	@PostMapping("/toAdd")
	public JSONResult<InitStandardResponseVO<AirportTransferControlVO>> init(@RequestBody @Valid InitStandardRequestVO request) {
		return JSONResult.success(airportTransferStandardService.init(request));
	}

	/**
	 * 修改差标名称
	 *
	 * @return
	 */
	@PostMapping("/updateStandardName")
	public JSONResult<UpdateNameResponseVO> updateStandardName(@RequestBody @Valid UpdateNameRequestVO request) {
		return JSONResult.success(airportTransferStandardService.updateStandardName(request));
	}

	/**
	 * 新增差标
	 *
	 * @param request
	 * @return
	 */
	@PostMapping("/save")
	public JSONResult<SaveAirportTransferControlResponseVO> save(@RequestBody @Valid SaveAirportTransferControlRequestVO request) {
		return JSONResult.success(airportTransferStandardService.save(request));
	}

	/**
	 * 更新接送机rc信息
	 *
	 * @param request
	 * @return
	 */
	@PostMapping("/updateRC")
	public JSONResult<UpdateReasonCodeResponseVO> updateRC(@RequestBody @Valid UpdateReasonCodeRequestVO request) {
		return JSONResult.success(airportTransferStandardService.updateRc(request));
	}

	/**
	 * 删除差标
	 *
	 * @param request
	 * @return
	 */
	@PostMapping("/delete")
	public JSONResult<DeleteStandardResponseVO> delete(@RequestBody @Valid DeleteStandardRequestVO request) {
		return JSONResult.success(airportTransferStandardService.delete(request));
	}

	/**
	 * 接送机差标描述
	 *
	 * @param request
	 * @return
	 */
	@RequestMapping("getTravelStandard")
	public JSONResult<AirportTransferStandardResponseBO> getTravelStandard(@RequestBody @Valid AirportTransferStandardRequestBO request) {
		log.info("接送机差标描述,request:{}", JsonUtils.toJsonString(request));
		return JSONResult.success(airportTransferStandardService.getTravelStandard(request));
	}

	/**
	 * 接送机差标
	 *
	 * @param request
	 * @return
	 */
	@RequestMapping("getTravelStandardDetail")
	public JSONResult<AirportTransferStandardDetailResponseBO> getTravelStandardDetail(@RequestBody @Valid AirportTransferStandardDetailRequestBO request) {
		log.info("接送机差标:{}",JsonUtils.toJsonString(request));
		return JSONResult.success(airportTransferStandardService.getTravelStandardDetail(request));
	}

}
